# Contributor: k0r10n <k0r10n.dev@gmail.com>
# Contributor: Jose-Luis Rivas <ghostbar@riseup.net>
# Maintainer: Carlo Landmeter <clandmeter@alpinelinux.org>
pkgname=libzip
pkgver=1.9.2
pkgrel=0
pkgdesc="C library for manipulating zip archives"
url="https://libzip.org/"
arch="all"
license="BSD-3-Clause"
depends_dev="bzip2-dev xz-dev zlib-dev zstd-dev"
makedepends="$depends_dev cmake openssl-dev perl samurai"
subpackages="$pkgname-dev $pkgname-doc $pkgname-tools"
source="https://libzip.org/download/libzip-$pkgver.tar.xz"

# secfixes:
#   1.3.0-r0:
#     - CVE-2017-14107

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DENABLE_BZIP2=ON \
		-DENABLE_LZMA=ON \
		-DENABLE_OPENSSL=ON \
		-DENABLE_ZSTD=ON \
		-DCMAKE_BUILD_TYPE=MinSizeRel
	cmake --build build
}

check() {
	ninja -C build check
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

tools() {
	pkgdesc="$pkgname cmp and merge tools"

	amove usr/bin
}

sha512sums="
82cb2533c25b5b540aa73856c958750d32eeceb192cce257eded15b396a24652041c8531f20366ac4c2dc6b7c0310c558d19c12b611576eccb07cfbaf98120b5  libzip-1.9.2.tar.xz
"
